package com.sky.controller.admin;

import com.sky.dto.FormFieldConfigDTO;
import com.sky.result.Result;
import com.sky.service.MaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/material")
@Slf4j
@Api(tags = "材料相关接口")
@CrossOrigin
public class MaterialController {

    @Autowired
    private MaterialService materialService;

    @PostMapping("/fields/all")
    @ApiOperation("查询所有表单字段信息（POST）")
    public Result<List<FormFieldConfigDTO>> getFieldsByTemplateIdsPost(@RequestBody List<Long> templateIds) {
        log.info("接收到的templateIds: {}", templateIds); // 添加这行日志
        log.info("查询表单字段信息, 参数: templateIds:{}", templateIds);
        List<FormFieldConfigDTO> fields = materialService.getFieldsByTemplateIds(templateIds);
        return Result.success(fields);
    }
}